<?php
namespace App\Http\Middleware;

use Closure;
use Response;
class EnableCrossRequestMiddleware {

    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        $response = $next($request);
        $response->header('Access-Control-Allow-Origin', '*');
        $response->header('Access-Control-Allow-Headers', 'Authorization, Origin, Content-Type, Cookie, Accept,X-Auth-Token');
        $response->header('Access-Control-Allow-Methods', 'GET, POST, PATCH, PUT, OPTIONS');
        $response->header('Access-Control-Allow-Credentials', 'true');
        $response->header("Expires",0);
        $response->header("Cache-Control","no-cache,no-store,must-revalidat,max-age=0");
        $response->header("Pragma","no-cache");
        return $response;
    }

}
